from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine

# 创建数据连接
from bili_homework.bili_models import Bilis

engine = create_engine("mysql+pymysql://root:root@127.0.0.1:3306/mogujie?charset=utf8", max_overflow=5,
                       encoding='utf-8')
session_maker = sessionmaker(bind=engine)
# 创建数据库会话
session = session_maker()


def save_data(title, addr, likes):
    bilis = Bilis()
    bilis.title = title
    bilis.addr = addr
    bilis.likes = likes
